<a href='https://github.com/angular/angular.js/edit/v1.4.x/src/ngMock/angular-mocks.js?message=docs($interval)%3A%20describe%20your%20change...#L412' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.4.7/src/ngMock/angular-mocks.js#L412' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$interval</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  

    <li>
      - service in module <a href="api/ngMock">ngMock</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Mock implementation of the $interval service.</p>
<p>Use <a href="api/ngMock/service/$interval#flush"><code>$interval.flush(millis)</code></a> to
move forward by <code>millis</code> milliseconds and trigger any functions scheduled to run in that
time.</p>

</div>




<div>
  

    

  <h2 id="usage">Usage</h2>
    
      <p><code>$interval(fn, delay, [count], [invokeApply], [Pass]);</code></p>


    

    
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        fn
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-function">function()</a>
      </td>
      <td>
        <p>A function that should be called repeatedly.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        delay
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-number">number</a>
      </td>
      <td>
        <p>Number of milliseconds between each function call.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        count
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-number">number</a>
      </td>
      <td>
        <p>Number of times to repeat. If not set, or 0, will repeat
  indefinitely.</p>

        <p><em>(default: 0)</em></p>
      </td>
    </tr>
    
    <tr>
      <td>
        invokeApply
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-boolean">boolean</a>
      </td>
      <td>
        <p>If set to <code>false</code> skips model dirty checking, otherwise
  will invoke <code>fn</code> within the <a href="api/ng/type/$rootScope.Scope#$apply">$apply</a> block.</p>

        <p><em>(default: true)</em></p>
      </td>
    </tr>
    
    <tr>
      <td>
        Pass
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">*</a>
      </td>
      <td>
        <p>additional parameters to the executed function.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
    
    <h3>Returns</h3>
<table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-promise">promise</a></td>
    <td><p>A promise which will be notified on each iteration.</p>
</td>
  </tr>
</table>

  
<h2>Methods</h2>
<ul class="methods">
  <li id="cancel">
    <h3><p><code>cancel(promise);</code></p>

</h3>
    <div><p>Cancels a task associated with the <code>promise</code>.</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        promise
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-promise">promise</a>
      </td>
      <td>
        <p>A promise from calling the <code>$interval</code> function.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-boolean">boolean</a></td>
    <td><p>Returns <code>true</code> if the task was successfully cancelled.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="flush">
    <h3><p><code>flush([millis]);</code></p>

</h3>
    <div><p>Runs interval tasks scheduled to be run in the next <code>millis</code> milliseconds.</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        millis
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-number">number</a>
      </td>
      <td>
        <p>maximum timeout amount to flush up until.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-number">number</a></td>
    <td><p>The amount of time moved forward.</p>
</td>
  </tr>
</table>
    

  </li>
  </ul>
  
  



  
</div>


